package com.itheima.bos.web.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.itheima.bos.domain.system.Permission;
import com.itheima.bos.service.system.PermissService;
import com.itheima.bos.web.common.action.BaseAction;
import com.opensymphony.xwork2.ActionContext;

@ParentPackage(value="json-default")
@Namespace("/")
@Scope("prototype")
@Controller
public class PermissionAction extends BaseAction<Permission>{
	
	@Autowired
	private PermissService permissionService;
	@Action(value="permission_list",results={@Result(name="success",type="json")})
	public String permissionQuery(){
		List<Permission> permissions = permissionService.findAll();
		ActionContext.getContext().getValueStack().push(permissions);
		return SUCCESS;	
	}
	@Action(value="permission_save",results={@Result(name="success",location="pages/system/permission.html",type="redirect")})
	public String save(){
		permissionService.save(model);
		return SUCCESS;
	}
}
